package mobi.weq.dao;

import java.sql.SQLException;
import java.util.Date;
import java.util.List;

import mobi.weq.model.SensorObservation;
import mobi.weq.util.map.Bounds;

public class PollutionData {
	public static SensorObservation getCurrentDataForPosition(double lat, double lng) throws SQLException {
		SensorObservationDao dao = new SensorObservationDao();
		List<SensorObservation> list = dao.getLatestObservationForThePosition(55.904523310371176, -3.4820418031250047);
		for (SensorObservation sensorObservation : list) {
			System.out.println(sensorObservation.getNo2());
			System.out.println(sensorObservation.getTimestamp());
		}
		System.out.println(list.size());
		return list.get(0);
	}

	public static List<SensorObservation> getCurrentGridsAndObservationForPosition(Bounds bounds, Date d) throws SQLException {
		SensorObservationDao dao = new SensorObservationDao();

		List<SensorObservation> list = dao.getGridsWithLatestObservationInTheBounds(bounds.southWest.latitude, bounds.southWest.longitude,
				bounds.northEast.latitude, bounds.northEast.longitude, d.getHours());

		// List<SensorObservation> list =
		// dao.getGridsWithLatestObservationInTheBounds(55.904523310371176,
		// -3.4820418031250047, 55.966523310371176,
		// -3.4560418031250047, d.getHours());
		System.out.println(list.size());
		return list;
	}

	public static void main(String[] args) {
		try {
			// getCurrentDataForPosition(0, 0);//
			getCurrentGridsAndObservationForPosition(null, new Date());
			// select * from so where latitude >= 55.904523310371175 and
			// latitude <= 55.91652331037118 and longitude >=
			// -3.4920418031250047 and longitude <= -3.4760418031250043 order by
			// timestamp desc limit 1

		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}

}
